#include "Logger.h"

#include <iostream>

static LogFuncType logFuncType_ = NULL;

void setLogFuncType(LogFuncType newFunc) { logFuncType_ = newFunc; }

void logInfo(const std::string& msg) { log(LogLevel::LogLevelInfo, msg); }

void logError(const std::string& msg) { log(LogLevel::LogLevelError, msg); }

void log(LogLevel logLevel, const std::string& msg) {
  if (logFuncType_ == NULL) {
    logDefault(logLevel, msg);
    return;
  }
  logFuncType_(logLevel, msg);
}

void logDefault(LogLevel logLevel, const std::string& msg) {
  switch (logLevel) {
    case LogLevel::LogLevelInfo:
      std::cout << msg;
      break;
    case LogLevel::LogLevelError:
      std::cerr << msg;
      break;
    default:
      break;
  }
}